var wyDatas = [{
	lsh: '1',
	zdbh: '8605******12056',
	ssfw: 'A区03#楼2单元3层3001',
	zdlx: '代缴电费',
	ssje: '300',
	jfsj: '20210627 09:20:34',
	zffs: '微信'
},
	{
		lsh: '2',
		zdbh: '8425******84456',
		ssfw: 'B区06#楼25单元33层1001',
		zdlx: '代缴水费',
		ssje: '356',
		jfsj: '20210627 09:20:34',
		zffs: '刷卡'
	},
	{
		lsh: '3',
		zdbh: '1716******56146',
		ssfw: 'A区04#楼2单元81层3201',
		zdlx: '代缴电费',
		ssje: '300',
		jfsj: '20210627 09:20:34',
		zffs: '现金'
	},
	{
		lsh: '4',
		zdbh: '2665******53535',
		ssfw: 'A区03#楼2单元3层3001',
		zdlx: '代缴电费',
		ssje: '300',
		jfsj: '20210627 09:20:34',
		zffs: '支付宝'
	},
	{
		lsh: '5',
		zdbh: '5561******53535',
		ssfw: 'F区03#楼2单元3层3001',
		zdlx: '代缴气费',
		ssje: '300',
		jfsj: '20210627 09:20:34',
		zffs: '支付宝'
	},
	{
		lsh: '6',
		zdbh: '5646******68461',
		ssfw: 'C区03#楼8单元56层3001',
		zdlx: '代缴电费',
		ssje: '556546',
		jfsj: '20210627 09:20:34',
		zffs: '微信'
	},
	{
		lsh: '7',
		zdbh: '2541******53535',
		ssfw: 'A区03#楼2单元3层4003',
		zdlx: '代缴电费',
		ssje: '890',
		jfsj: '20210627 09:20:34',
		zffs: '支付宝'
	},
	{
		lsh: '8',
		zdbh: '2665******53535',
		ssfw: 'A区07#楼2单元3层3001',
		zdlx: '代缴电费',
		ssje: '355',
		jfsj: '20210627 09:20:34',
		zffs: '刷卡'
	}
]
var operid = -1;
// window.onload = function() {
	distable();
	del();
	edit();
	add();
	search();
// }
//动态生成数据
function distable() {
	$("tbody").html("")
	var tbody = $('tbody');
	for (var i = 1; i <= wyDatas.length; i++) {
		var item = wyDatas[i - 1]
		tbody.append('<tr> ' +
			'<td>' + i + '</td>' +
			'<td>' + item.zdbh + '</td>' +
			'<td>' + item.ssfw + '</td>' +
			'<td>' + item.zdlx + '</td>' +
			'<td>' + item.ssje + '</td>' +
			'<td>' + item.jfsj + '</td>' +
			'<td>' + item.zffs + '</td>' +
			'<td id="but"><button class="del" data-index="' + i +
			'">删除</button>&nbsp;<button class="edit" data-index="' + i +
			'">修改</button>&nbsp;<button class="save" style="display:none">保存</button></td>' +
			'</tr>')
	}
}
//删除
function del() {
	$("tbody").on('click', '.del', function() {
		console.log(this);
		var index = $(this).attr('data-index');
		wyDatas.splice(index - 1, 1);
		distable()
	})
}

//新增
function add() {
	$(".add").click(function() {
		operid = -1
	})
	$("#save").click(function() {
		var lsh = $("#lsh").val();
		var zdbh = $("#dzbh").val();
		var ssfw = $("#ssfw").val();
		var zdlx = $("#zdlm").val();
		var ssje = $("#ssje").val();
		var jfsj = $("#jfsj").val();
		var zffs = $("#zffs").val();
		var obj = {
			"lsh": lsh,
			"zdbh": zdbh,
			"ssfw": ssfw,
			"zdlx": zdlx,
			"ssje": Number(ssje),
			"jfsj": jfsj,
			"zffs": zffs
		};
		if (operid == -1) {
			wyDatas.push(obj);
		} else {
			wyDatas.splice(operid, 1, obj);
		}
		distable()
	})
}
//修改
function edit() {
	$("tbody").on('click', '.edit', function() {
		var index = $(this).attr('data-index');
		operid = index;
		$("#myModal").modal('show');
		$("#lsh").val(wyDatas[index - 1].lsh);
		$("#zdbh").val(wyDatas[index - 1].zdbh);
		$("#ssfw").val(wyDatas[index - 1].ssfw);
		$("#zdlx").val(wyDatas[index - 1].zdlx);
		$("#ssje").val(wyDatas[index - 1].ssje);
		$("#jfsj").val(wyDatas[index - 1].jfsj);
		$("#zffs").val(wyDatas[index - 1].zffs);
	})
	$('#moren').prop('selected', 'selected')
}
//查询
function search() {
	$('.cxbh').keydown(function() {
		var shuru = $(this).val();
		var result = new RegExp(shuru);
		var outHtml = '';
		var findConfirm = 0;
		if (shuru != '') {
			for (var i = 0; i < wyDatas.length; i++) {
				var match = wyDatas[i].zdbh;
				if (result.test(match)) {
					outHtml +=
						"<tr>" +
						"<td>" + wyDatas[i].lsh + "</td>" +
						"<td>" + wyDatas[i].zdbh + "</td>" +
						"<td>" + wyDatas[i].ssfw + "</td>" +
						"<td>" + wyDatas[i].zdlx + "</td>" +
						"<td>" + wyDatas[i].ssje + "</td>" +
						"<td>" + wyDatas[i].jfsj + "</td>" +
						"<td>" + wyDatas[i].zffs + "</td>" +
						"<td><button class=\"btn btn-default del\" data-index='" + i +
						"'>删除</button><button class=\"btn btn-default edit\"  data-index='" + i +
						"'>编辑</button></td>" +
						"</tr>";
					$("#userTable").html(outHtml);
					// $('.search2').prev().val('');
					findConfirm = 1;
					continue;
				}
			}
			if (findConfirm == 0) {
				outHtml = "<div><p>未找到你要的内容</p><button class=\"btn btn-default back \">返回</button></div>";
				$("#uesrTable").html(outHtml);
				$('.search1').val('');
				$('.back').on('click', function() {
					distable();
				})
			}
		}
	})
	$('.cxdz').keydown(function() {
		var shuru = $(this).val();
		var result = new RegExp(shuru);
		var outHtml = '';
		var findConfirm = 0;
		if (shuru != '') {
			for (var i = 0; i < wyDatas.length; i++) {
				var match = wyDatas[i].ssfw;
				if (result.test(match)) {
					outHtml +=
						"<tr>" +
						"<td>" + wyDatas[i].lsh + "</td>" +
						"<td>" + wyDatas[i].zdbh + "</td>" +
						"<td>" + wyDatas[i].ssfw + "</td>" +
						"<td>" + wyDatas[i].zdlx + "</td>" +
						"<td>" + wyDatas[i].ssje + "</td>" +
						"<td>" + wyDatas[i].jfsj + "</td>" +
						"<td>" + wyDatas[i].zffs + "</td>" +
						"<td><button class=\"btn btn-default del\" data-index='" + i +
						"'>删除</button><button class=\"btn btn-default edit\"  data-index='" + i +
						"'>编辑</button></td>" +
						"</tr>";
					$("#userTable").html(outHtml);
					// $('.search2').prev().val('');
					findConfirm = 1;
					continue;
				}
			}
			if (findConfirm == 0) {
				outHtml = "<div><p>未找到你要的内容</p><button class=\"btn btn-default back \">返回</button></div>";
				$("#uesrTable").html(outHtml);
				$('.search1').val('');
				$('.back').on('click', function() {
					distable();
				})
			}
		}
	})
	$('.xl1').change(function() {
		var shuru = $(this).val();
		var result = new RegExp(shuru);
		var outHtml = '';
		var findConfirm = 0;
		if (shuru != '') {
			for (var i = 0; i < wyDatas.length; i++) {
				var match = wyDatas[i].zdlx;
				if (result.test(match)) {

					outHtml +=
						"<tr>" +
						"<td>" + wyDatas[i].lsh + "</td>" +
						"<td>" + wyDatas[i].zdbh + "</td>" +
						"<td>" + wyDatas[i].ssfw + "</td>" +
						"<td>" + wyDatas[i].zdlx + "</td>" +
						"<td>" + wyDatas[i].ssje + "</td>" +
						"<td>" + wyDatas[i].jfsj + "</td>" +
						"<td>" + wyDatas[i].zffs + "</td>" +
						"<td><button class=\"btn btn-default del\" data-index='" + i +
						"'>删除</button><button class=\"btn btn-default edit\"  data-index='" + i +
						"'>编辑</button></td>" +
						"</tr>";
					$("#userTable").html(outHtml);
					// $('#search4').prev().val('');
					findConfirm = 1;

					continue;
				} else if (result == '/全部/') {
					distable();
					break
				}
			}
			if (findConfirm == 0 && result != '/全部/') {
				outHtml = "<div><p>未找到你要的内容</p><button class=\"btn btn-default back \">返回</button></div>";
				$("#userTable").html(outHtml);
				// $('.search3').prev().val('');
				$('.back').on('click', function() {
					distable()
				})
			}
		};
	})
	$('.xl2').change(function() {
		var shuru = $(this).val();
		var result = new RegExp(shuru);
		var outHtml = '';
		var findConfirm = 0;
		if (shuru != '') {
			for (var i = 0; i < wyDatas.length; i++) {
				var match = wyDatas[i].zffs;
				if (result.test(match)) {

					outHtml +=
						"<tr>" +
						"<td>" + wyDatas[i].lsh + "</td>" +
						"<td>" + wyDatas[i].zdbh + "</td>" +
						"<td>" + wyDatas[i].ssfw + "</td>" +
						"<td>" + wyDatas[i].zdlx + "</td>" +
						"<td>" + wyDatas[i].ssje + "</td>" +
						"<td>" + wyDatas[i].jfsj + "</td>" +
						"<td>" + wyDatas[i].zffs + "</td>" +
						"<td><button class=\"btn btn-default del\" data-index='" + i +
						"'>删除</button><button class=\"btn btn-default edit\"  data-index='" + i +
						"'>编辑</button></td>" +
						"</tr>";
					$("#userTable").html(outHtml);
					// $('#search4').prev().val('');
					findConfirm = 1;

					continue;
				} else if (result == '/全部/') {
					distable();
					break
				}
			}
			if (findConfirm == 0 && result != '/全部/') {
				outHtml = "<div><p>未找到你要的内容</p><button class=\"btn btn-default back \">返回</button></div>";
				$("#userTable").html(outHtml);
				// $('.search3').prev().val('');
				$('.back').on('click', function() {
					distable()
				})
			}
		};
	})
}
var zuocedaohuang = document.querySelectorAll("#zuocedaohuang>ul>li>div");
//物联设备
$("#bs-example-navbar-collapse-1 ul:nth-child(3) li:nth-child(2) a").click(function () {
	$("body").load("WuJiaHanWuLianSheBei.html");
})
//主页
$("#zuocedaohuang>ul>li:nth-child(1)").click(function () {
	$("body").load("index.html");
})
//修改密码
$("#zuocedaohuang>ul>li:nth-child(8)>ul>li:first-child").click(function () {
	$("body").load("yaoketongxiugaimm.html");
})
$(".dropdown-menu>li:first-child").click(function () {
	$("body").load("yaoketongxiugaimm.html");
})
//人员管理
$("#zuocedaohuang>ul>li:nth-child(2)>ul>li").click(function () {
	$("body").load("WuJiaHanRenYuanGuanLi.html");
})
//初始化
$("#zuocedaohuang>ul>li:nth-child(8)>ul>li:last-child").click(function () {
	$("body").load("chushihua.html");
})
//主页
$("#bs-example-navbar-collapse-1 ul:nth-child(3) li:nth-child(1) a").click(function () {
	$("body").load("index.html");
})

//物业管理
$("#zuocedaohuang>ul>li:nth-child(5)>ul>li:first-child").click(function () {
	$("body").load("HeLuYiJiaoFeiJiLu.html");
})
//订单管理
$("#zuocedaohuang>ul>li:nth-child(5)>ul>li:nth-child(2)").click(function () {
	$("body").load("HeLuYiDaiJiaoDingDan.html");
})
//收款账号
$("#zuocedaohuang>ul>li:nth-child(5)>ul>li:nth-child(3)").click(function () {
	$("body").load("HeLuYiShouKuanZhangHao.html");
})

//房源管理
$("#zuocedaohuang>ul>li:nth-child(3)>ul>li:first-child").click(function () {
	$("body").load("renchengdongfangyuanhuanli.html");
})
//房屋档案
$("#zuocedaohuang>ul>li:nth-child(3)>ul>li:nth-child(2)").click(function () {
	$("body").load("renchengdongfangwudangan.html");
})

//车位管理
$("#zuocedaohuang>ul>li:nth-child(4)>ul>li:first-child").click(function () {
	$("body").load("cx-chewguanli.html");
})
//车辆管理
$("#zuocedaohuang>ul>li:nth-child(4)>ul>li:nth-child(2)").click(function () {
	$("body").load("cx-chelguanli.html");
})

//工单配置
$("#zuocedaohuang>ul>li:nth-child(6)>ul>li:first-child").click(function () {
	$("body").load("第一个页面.html");
})
//报修管理
$("#zuocedaohuang>ul>li:nth-child(6)>ul>li:nth-child(2)").click(function () {
	$("body").load("第二个页面.html");
})
//物业信息
$("#zuocedaohuang>ul>li:nth-child(7)>ul>li:nth-child(3)").click(function () {
	$("body").load("YaoKeTongWuYeXingXi.html");
})
//信息服务
$("#zuocedaohuang>ul>li:nth-child(7)>ul>li:first-child").click(function () {
	$("body").load("LiuXueQiXinXiFuWu.html");
})
//账单配置
$("#zuocedaohuang>ul>li:nth-child(7)>ul>li:nth-child(2)").click(function () {
	$("body").load("LiuXueQiZhangDanPeiZhi.html");
})

$(".dropdown-toggle").click(function () {
	if (navpanding==1){
		$(".dropdown-menu").css("display","block");
		$(".dropdown-toggle").css("background-color","rgb(221,221,221)")
		navpanding=2;
	}else {
		$(".dropdown-menu").css("display","none");
		$(".dropdown-toggle").css("background-color","rgb(65,92,133)")
		navpanding=1;
	}
})
for(var i = 0 ;i<zuocedaohuang.length;i++){
    zuocedaohuang[i].onclick=function () {
        var liClick = this.parentNode;
        var haizi=liClick.querySelectorAll("ul>li");
        var liHeight = liClick.style.height;
        for(var n = 1 ;n<zuocedaohuang.length;n++){
            var fa=[];
            fa[n]= zuocedaohuang[n].parentNode;
            fa[n].style.height="50px";
            fa[n].style.transition="all 0.2s";
            zuocedaohuang[n].style.color="black";
            zuocedaohuang[n].querySelector("span").style.transform="rotatez(0deg)";
        }
        if(liHeight=="50px"){
            if(haizi&&haizi.length>0){
                this.style.color="black";
                liClick.style.height=50+haizi.length*50+"px";
                this.querySelector("span").style.transform="rotatez(180deg)";
                liClick.style.transition="all 0.2s";
            }
        }else {
            this.style.color="black";
            liClick.style.height="50px";
            this.querySelector("span").style.transform="rotatez(0deg)";
            liClick.style.transition="all 0.2s";
            this.querySelector("span").style.transform="rotatez(0deg)";
        }
    }
}
$(window).scroll(function () {
    var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
    var i=scrollTop;
    if (scrollTop>500){
        $("#zuocedaohuang>ul").css("margin-top",scrollTop+"px");
    }
    if (scrollTop<500){
        $("#zuocedaohuang>ul").css("margin-top","0");
    }
})
